package idea.think.custom_ui;

import idea.think.R;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

/**
 * @author kimjiho
 * 커스텀 토스트 메시지
 */
public class CustomToast extends Toast {

	private Context mContext;
	private View v;
	
	public CustomToast(Context context){
		super(context);
		this.mContext = context;
		this.setCustomView();
	}
	
	public CustomToast(Context context, String msg){
		super(context);
		this.mContext = context;
		this.setCustomView();
		this.setText(msg);
	}
		
	public Context getContext(){
		if(this.mContext != null)
			return mContext;
		else
			return null;
	}

	@Override
	public void setDuration(int duration) {
		super.setDuration(3);
	}
	
	@Override
	public void setText(CharSequence s) {
		((TextView)v.findViewById(R.id.tId)).setText(s);
	}
	
	@Override
	public void setGravity(int gravity, int xOffset, int yOffset) {
		super.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
	}
	
	@Override
	public void setView(View view) {		
		super.setView(view);
	}
	
	public void setCustomView(){
		v = View.inflate(mContext, R.layout.toast, null);
		super.setView(v);
	}
}
